import { configureStore } from "@reduxjs/toolkit";
import global from "./modules/global";
import menu from "./modules/menu";
import tabs from "./modules/tabs";
import auth from "./modules/auth";
import breadcrumb from "./modules/breadcrumb";
import { combineReducers } from "@reduxjs/toolkit";
import storage from "redux-persist/lib/storage";
import { persistReducer, persistStore } from "redux-persist"; //数据持久化
import reduxThunk from "redux-thunk"

// combineReducers合并reducer
const reducers = combineReducers({
    global,
    menu,
    tabs,
    auth,
    breadcrumb
})

const presistConfig = {
    key:'redux-state',
    storage
}

const persistedReducer = persistReducer(presistConfig, reducers)

export const store = configureStore({
    reducer: persistedReducer,
    middleware: [reduxThunk]
})

export const persistor = persistStore(store)